<?php


namespace app\widgets;


use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\Menu;

class BaseMenuWidget extends Menu {

    public $encodeLabels = FALSE;
    public $activeCssClass = 'active';
    public $options = ['class' => 'nav'];
    public $itemOptions = ['class' => 'nav-item'];
    public $linkOptions = ['class' => 'nav-link'];

    protected function renderItem($item) {
        if (!isset($item['url']) || empty($item['url'])) {
            $url = 'javascript:void(0);';
        } else {
            $url = Html::encode(Url::to($item['url']));
        }
        $linkOptions = $this->linkOptions;
        if (isset($item['linkOptions'])) {
            $linkOptions = ArrayHelper::merge($linkOptions, $item['linkOptions']);
        }
        $html = Html::a($item['label'], $url, $linkOptions);
        if(isset($item['append'])){
            $html .= $item['append'];
        }
        return $html;
    }
}